package com.lesserpand.rabbitmq.rabbitmq.callback;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.RabbitTemplate;

/**
 * @author bailuo
 * @version 2.0
 * @Description ReturnCallback接口用于实现消息发送到RabbitMQ交换器，但无相应队列与交换器绑定时的回调。
 * @Date Created in 2019/1/8 13:05
 */
public class MsgSendReturnCallBack implements RabbitTemplate.ReturnCallback {

    private static final Logger LOGGER = LoggerFactory.getLogger(MsgSendReturnCallBack.class);

    /**
     * @param message
     * @param replyCode
     * @param replyText
     * @param exchange
     * @param routingKey
     */
    @Override
    public void returnedMessage(Message message, int replyCode, String replyText, String exchange, String routingKey) {
        LOGGER.info(String.format(message.getMessageProperties().getCorrelationId() + " 发送失败"));
    }
}
